package map;

import java.util.*;

public class MapDemo2 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("英语",57);
        map.put("数学",66);
        map.put("物理",99);
        map.put("化学",32);
        map.put("体育",78);
        System.out.println(map);
        Set<String> set = map.keySet();
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            String next = it.next();
            System.out.println("key:"+next);
        }
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for ( Map.Entry<String, Integer> entry: entries) {
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+":"+value);
        }
        Collection<Integer> values = map.values();
        for (Integer integer :values) {
            System.out.println("value:"+integer);
        }
    }
}
